"use strict";
const Joi = require('joi');
const CheckUtil = require("../utils/check");
const BasicsCtl = require("../basics/clz/basectl");
const HomeImpl = require("../service/home");


class HomeCtl extends BasicsCtl {

  constructor(context) {
    super(context);
    this.homeImpl = new HomeImpl(this.cloud);
  }


  /**
   * 类型列表
   */
  async findKindList() {
    return await this.homeImpl.findKindList();
  }

  /**
   * 材质列表
   */
  async findMaterialList() {
    return await this.homeImpl.findMaterialList();
  }

  /**
   * 配件列表
   */
  async findPartslList() {
    const rule = {
      type: Joi.number().integer().required()
    };
    CheckUtil.validate(rule, this.params);
    return await this.homeImpl.findPartslList(this.params);
  }


  /**
   * 保存订单
   */
  async saveOrder() {
    const rule = {
      itemId: Joi.string().required(),
      deatils: Joi.array().required()
    };
    CheckUtil.validate(rule, this.params);
    return await this.homeImpl.saveOrder(this.params);
  }
}
module.exports = HomeCtl;